import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;

public class SdServerRMI extends UnicastRemoteObject {

    private static String URL;
    private static String Div_Server_URL;
    private static String Mult_Server_URL;

    public SdServerRMI() throws RemoteException {
        super();
    }

    public static void main(String[] args) {
        if (System.getSecurityManager() == null) 
            System.setSecurityManager(new RMISecurityManager());

        
        try {
            Arquivo arq = new Arquivo();
            arq.LeIni("sdserverrmi.ini");

            URL = (String) arq.values[0];
            Div_Server_URL = (String) arq.values[1];
            Mult_Server_URL = (String) arq.values[2];

            
            CalculadoraImpl server_calc = new CalculadoraImpl(Div_Server_URL, Mult_Server_URL);
            System.out.println("Servidor de Calculadora criado...");

            Naming.rebind("rmi://" + URL, server_calc);
            System.out.println("Servidor de Calculadora ativo no endereço "+URL+"...");

        } catch (Exception e) {
            System.out.println("Msg err: " + e.getMessage());
            e.printStackTrace();
        }
    }
}